var o = {};

var area = new Function();
area.prototype = o;

o.edit=function(id,aname){
	$.ligerDialog.prompt('编辑',aname, function(yes, value)
	{
		if (yes){
			$.ajax( {
		 		type : "POST",
		 		url : "index-editArea.action",
		 		data : "important.name="+value+"&areaId="+id,
		 		success : function(msg) {
					alert(msg.jsonResult);
		 			window.location.reload(false);
		 		},
		 		error:function (XMLHttpRequest, textStatus, errorThrown) {
		 		    alert("出错了："+errorThrown);
		 		}
		 	});
		}
	}); 
	
};

o.show=function(id,input){
	$.ajax( {
 		type : "POST",
 		url : "index-showArea.action",
 		data : "important.show="+$(input).attr("checked")+"&areaId="+id,
 		success : function(msg) {
 			window.location.reload(false);
 		},
 		error:function (XMLHttpRequest, textStatus, errorThrown) {
 		    alert("出错了："+errorThrown);
 		}
 	});
	
};

o.pos=function(id,lid){
	$.ajax( {
 		type : "POST",
 		url : ROOT+"/front/index-changePosition.action",
 		data : "id="+id+"&lid="+lid,
 		success : function(msg) {
 			window.location.reload(false);
 		},
 		error:function (XMLHttpRequest, textStatus, errorThrown) {
 		    alert("出错了："+errorThrown);
 		}
 	});
	
};

o.top=function(id,areaId){
	$.ajax( {
 		type : "POST",
 		url : ROOT+"/front/index-topPosition.action",
 		data : "id="+id+"&areaId="+areaId,
 		success : function(msg) {
 			window.location.reload(false);
 		},
 		error:function (XMLHttpRequest, textStatus, errorThrown) {
 		    alert("出错了："+errorThrown);
 		}
 	});
	
};
o.top1=function(id){
	$.ajax( {
 		type : "POST",
 		url : ROOT+"/front/index-topPosition1.action",
 		data : "id="+id,
 		success : function(msg) {
 			window.location.reload(false);
 		},
 		error:function (XMLHttpRequest, textStatus, errorThrown) {
 		    alert("出错了："+errorThrown);
 		}
 	});
	
};
o.selectAll=function(obj){
	if (obj.attr('checked') == true) {
		$('.selectItem').attr('checked', 'checked');
	} else {
		$('.selectItem').attr('checked', '');
	}
};

o.setSugest=function(){
	var ids = "";
	$('.selectItem').each( function() {
		if ($(this).attr("checked")) {
			if (ids == "")
				ids = $(this).val();
			else
				ids = ids + "," + $(this).val();
		}
	});
	if(ids==""){
		alert("请选择要设置的记录!");
		return;
	}
	var d=$("#txtDate").val();
	if(d==""){
		alert("请选择推荐时间!");
		return;
	}
	$.ajax( {
		type : "POST",
		url : "index-setSugest.action",
		data : "ids="+ids+"&sugestDate="+d,
		success : function(msg) {
			alert(msg.jsonResult);
			window.location.reload(false);
		},
		error:function (XMLHttpRequest, textStatus, errorThrown) {
		    // 通常 textStatus 和 errorThrown 之中
		    // 只有一个会包含信息
		    alert("出错了："+errorThrown);
		}
	});
}
